package org.example.commonapi.domain;


import lombok.Data;

import java.util.List;

@Data
public class R<T> {

    private  T  data;

    private Integer code;

    private String message;


    public R(T data, Integer code, String message){
        this.data = data;
        this.code = code;
        this.message = message;
    }
//    成功带参数
    public static <T> R<T> success(T data){
        return new R<T>(data,1,"success");
    }
//    成功不带参数
    public static <T> R<T> success(){
        return new R<T>(null,1,"success");
    }
//    失败带报错信息
    public static <T> R<T> error(String message){
        return new R<T>(null,0,message);
    }

}
